package demo13;

import java.util.ArrayList;
import java.util.List;

class Solution {
    List<List<Integer>> ret = new ArrayList<>();
    List<Integer> path = new ArrayList<>();
    int len;
    public List<List<Integer>> subsets(int[] nums) {
        len = nums.length;
        dfs(nums,0);
        ret.add(new ArrayList<>());
        return ret;
    }

    private void dfs(int[] nums, int pos) {
        for(int i = pos; i < len; i++) {
            path.add(nums[i]);
            dfs(nums,i+1);
            ret.add(new ArrayList<>(path));
            path.remove(path.size()-1);
        }
    }
}